package com.voxel.sense.infomsg.module.publish;

import android.graphics.Color;
import android.view.View;
import android.widget.TextView;

import com.example.com.common.view.recycler.RecyclerAdapter;
import com.voxel.sense.infomsg.R;
import com.voxel.sense.infomsg.data.bean.ConditionBean;
import cyy.example.com.facotry.Factory;
import com.voxel.sense.infomsg.widget.adapter.AbsPickRecyclerAdapter;

import butterknife.BindView;

/**
 * Created by ChenYiYao on 2018/8/31.
 */
public class PublishTypeAdatper extends AbsPickRecyclerAdapter {


    public PublishTypeAdatper(AdapterListener<ConditionBean> listener) {
        super(listener);
    }

    public PublishTypeAdatper() {
        this(null);
    }

    @Override
    protected boolean handlerSatu(ConditionBean conditionBean) {
        return true;
    }

    @Override
    protected int getItemViewType(int position, ConditionBean conditionBean) {
        return R.layout.item_recycler_publish_type;
    }

    @Override
    protected RecyclerAdapter.ViewHolder<ConditionBean> onCreateViewHolder(View root, int viewType) {
        return new ViewHolder(root);
    }


    static class ViewHolder extends RecyclerAdapter.ViewHolder<ConditionBean> {
        @BindView(R.id.tv_des)
        TextView tv_des;
        public ViewHolder(View itemView) {
            super(itemView);
        }

        @Override
        protected void onBind(ConditionBean bean) {
            tv_des.setText(bean.getDesc());

            boolean select = bean.isSelect();
            tv_des.setText(bean.getDesc());
            tv_des.setSelected(select);
            if (select) {
                tv_des.setTextColor(Color.WHITE);
            } else {
                int color = Factory.app().getResources().getColor(R.color.pick_drop_menu_btn_text);
                tv_des.setTextColor(color);
            }

        }
    }

}
